package com.learn.springboot.repository;

import com.learn.springboot.pojo.User;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;

/**
 * @author dyz
 * @program learning
 * @create 2019-08-13 10:27
 */
public interface UserRepository extends CrudRepository<User, Long> {

    /**
     * 自定义条件查询
     *
     * @param name name
     * @return user
     */
    User findByNameIsLike(String name);

    /**
     * 自定义SQL查询
     *
     * @param name name
     * @return user
     */
    @Query("FROM User u WHERE u.name = :name")
    User findUser(@Param("name") String name);
}
